package com.qilu.pe.dao.http;

import android.text.TextUtils;

import com.qilu.pe.base.Global;
import com.qilu.pe.support.util.Logg;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Response;

// 获取响应头的token,解决登录过期的问题
public class TokenInterCeptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        Response response = chain.proceed(chain.request());

        String headerToken = response.header("Authorization");

        Logg.i("headerToken = " + headerToken);

        if (!TextUtils.isEmpty(headerToken)) {
            Global.HEADER = headerToken;
        }
        return response;
    }
}
